package com.flurry.android;

import android.app.Activity;
import android.app.KeyguardManager;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Pair;
import android.view.ViewGroup;
import com.flurry.org.apache.avro.io.BinaryDecoder;
import com.flurry.org.apache.avro.io.BinaryEncoder;
import com.flurry.org.apache.avro.io.DecoderFactory;
import com.flurry.org.apache.avro.io.EncoderFactory;
import com.flurry.org.apache.avro.specific.SpecificDatumReader;
import com.flurry.org.apache.avro.specific.SpecificDatumWriter;
import com.flurry.org.apache.avro.specific.SpecificRecordBase;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;

public class FlurryAds
  implements IFlurryAds, au
{
  private static List<Integer> gR;
  private static DecoderFactory gS;
  private static el gT;
  private static FlurryAds hF;
  static String p = "FlurryAgent";
  private String aC;
  private Map<ReportedIdType, ByteBuffer> aH;
  private long aL;
  private long aM;
  private ea gU;
  private boolean gV = false;
  private boolean gW = false;
  private File gX = null;
  private File gY = null;
  private String gZ;
  private Map<String, String> hA;
  private AdUnit hB;
  private fm hC;
  private final Map<String, String> hD;
  private final Set<String> hE;
  private boolean hG;
  private dz hH;
  private byte[] ha = null;
  private boolean hb = true;
  private boolean hc = false;
  private volatile String hd = null;
  private volatile String he = null;
  private volatile Location hf;
  private volatile Map<String, String> hg;
  private cw hh;
  private AdUnit hi;
  private long hj;
  aa hk;
  private String hl;
  private Handler hm;
  gv hn;
  ca ho = ca.aq();
  private ICustomAdNetworkHandler hp;
  private final m hq;
  private final ba hr;
  private FlurryAdListener hs;
  private int ht;
  private final List<Activity> hu;
  volatile List<cw> hv = new CopyOnWriteArrayList();
  private volatile Map<String, cw> hw = new HashMap();
  private volatile List<cw> hx = new ArrayList();
  private volatile List<String> hy = new ArrayList();
  private volatile boolean hz = false;

  FlurryAds()
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("open", "directOpen");
    localHashMap.put("expand", "doExpand");
    localHashMap.put("collapse", "doCollapse");
    this.hD = Collections.unmodifiableMap(localHashMap);
    HashSet localHashSet = new HashSet();
    localHashSet.addAll(Arrays.asList(new String[] { "notifyUser", "nextFrame", "closeAd", "expandAd", "collapseAd", "verifyURL" }));
    this.hE = Collections.unmodifiableSet(localHashSet);
    HandlerThread localHandlerThread = new HandlerThread("FlurryAdThread");
    localHandlerThread.start();
    this.hm = new Handler(localHandlerThread.getLooper());
    this.hk = new aa();
    Integer[] arrayOfInteger = new Integer[6];
    arrayOfInteger[0] = Integer.valueOf(0);
    arrayOfInteger[1] = Integer.valueOf(1);
    arrayOfInteger[2] = Integer.valueOf(2);
    arrayOfInteger[3] = Integer.valueOf(3);
    arrayOfInteger[4] = Integer.valueOf(4);
    arrayOfInteger[5] = Integer.valueOf(5);
    gR = Arrays.asList(arrayOfInteger);
    gS = new DecoderFactory();
    gT = new el(this);
    this.gU = new ea(this);
    this.hn = new gv();
    this.aC = Build.VERSION.RELEASE;
    this.gZ = Build.DEVICE;
    this.hg = new HashMap();
    this.hq = new l();
    this.hr = new i();
    this.hu = new ArrayList();
  }

  private void C(String paramString)
  {
    this.hn.C(paramString);
  }

  private cw a(cw paramcw, String paramString, boolean paramBoolean, Map<String, String> paramMap)
  {
    try
    {
      new StringBuilder().append("changeAdState(").append(paramcw).append(", ").append(paramString).append(", ").append(paramBoolean).append(", ").append(paramMap).append(")").toString();
      try
      {
        if (!this.hv.contains(paramcw))
        {
          this.hv.add(paramcw);
          new StringBuilder().append("changeAdState added adLog = ").append(paramcw).toString();
        }
        paramcw.a(a(paramString, paramBoolean, paramMap));
        return paramcw;
      }
      finally
      {
      }
    }
    finally
    {
    }
  }

  private fm a(Context paramContext, AdUnit paramAdUnit)
  {
    this.hB = paramAdUnit;
    if (paramAdUnit == null)
      return null;
    List localList = paramAdUnit.getAdFrames();
    if ((localList == null) || (localList.isEmpty()))
      return null;
    AdFrame localAdFrame = (AdFrame)localList.get(0);
    int i = localAdFrame.getBinding().intValue();
    String str1 = localAdFrame.getContent().toString();
    String str2 = localAdFrame.getAdSpaceLayout().getFormat().toString();
    String str3 = localAdFrame.getAdGuid().toString();
    cw localcw1 = (cw)this.hw.get(str3);
    if (localcw1 == null);
    for (cw localcw2 = ct.a(this, str3); ; localcw2 = localcw1)
    {
      onEvent(new gt("filled", Collections.emptyMap(), paramContext, paramAdUnit, localcw2, 0), this, 1);
      AdCreative localAdCreative = ct.b(localAdFrame.getAdSpaceLayout());
      if ((this.hB == null) || (this.hB != paramAdUnit));
      while (true)
      {
        return this.hC;
        this.hC = null;
        ICustomAdNetworkHandler localICustomAdNetworkHandler = this.hp;
        if ((i == 4) && (localICustomAdNetworkHandler != null))
        {
          AdNetworkView localAdNetworkView = localICustomAdNetworkHandler.getAdFromNetwork(paramContext, localAdCreative, str1);
          if (localAdNetworkView != null)
          {
            localAdNetworkView.R = this;
            localAdNetworkView.S = localcw2;
            localAdNetworkView.U = 0;
            localAdNetworkView.T = paramAdUnit;
            this.hC = new ex(localAdNetworkView, paramAdUnit);
          }
        }
        else if (str2.equals("takeover"))
        {
          this.hh = localcw2;
          this.hi = paramAdUnit;
          ae localae = this.hr.a(paramContext, this, localcw2, paramAdUnit);
          if (localae != null)
            this.hC = new bs(localae, paramAdUnit);
        }
        else
        {
          p localp = this.hq.b(paramContext, this, localcw2, paramAdUnit);
          if (localp != null)
          {
            this.hC = new ex(localp, paramAdUnit);
          }
          else
          {
            cy.g(p, "Failed to create view for ad network: " + str1 + ", network is unsupported on Android, or no ICustomAdNetworkHandler was registered or it failed to return a view.");
            onEvent(new gt("renderFailed", Collections.emptyMap(), paramContext, paramAdUnit, localcw2, 0), this, 1);
          }
        }
      }
    }
  }

  private gc a(String paramString, boolean paramBoolean, Map<String, String> paramMap)
  {
    try
    {
      gc localgc = new gc(paramString, paramBoolean, bh(), paramMap);
      return localgc;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  private static <A extends SpecificRecordBase> A a(byte[] paramArrayOfByte, Class<A> paramClass)
  {
    BinaryDecoder localBinaryDecoder = gS.binaryDecoder(new ByteArrayInputStream(paramArrayOfByte), null);
    try
    {
      SpecificRecordBase localSpecificRecordBase = (SpecificRecordBase)new SpecificDatumReader(paramClass).read(null, localBinaryDecoder);
      return localSpecificRecordBase;
    }
    catch (ClassCastException localClassCastException)
    {
      new StringBuilder().append("ClassCastException in parseAvroBinary:").append(localClassCastException.getMessage()).toString();
      new StringBuilder().append("ClassCastException in parseAvroBinary: bytes = ").append(paramArrayOfByte).append(" type = ").append(paramClass.getSimpleName()).toString();
      return null;
    }
    catch (IOException localIOException)
    {
      new StringBuilder().append("IOException in parseAvroBinary:").append(localIOException.getMessage()).toString();
      new StringBuilder().append("IOException in parseAvroBinary: bytes = ").append(paramArrayOfByte).append(" type = ").append(paramClass.getSimpleName()).toString();
    }
    return null;
  }

  private static String a(Intent paramIntent)
  {
    if (paramIntent == null)
      return null;
    return paramIntent.getStringExtra("adSpaceName");
  }

  private String a(cw paramcw, AdUnit paramAdUnit, y paramy, String paramString)
  {
    Pattern localPattern = Pattern.compile(".*?(%\\{\\w+\\}).*?");
    for (Matcher localMatcher = localPattern.matcher(paramString); localMatcher.matches(); localMatcher = localPattern.matcher(paramString))
      paramString = this.gU.a(paramcw, paramAdUnit, paramString, localMatcher.group(1));
    return paramString;
  }

  private static List<y> a(AdFrame paramAdFrame, gt paramgt)
  {
    ArrayList localArrayList = new ArrayList();
    List localList = paramAdFrame.getCallbacks();
    String str1 = paramgt.jf;
    Iterator localIterator1 = localList.iterator();
    while (localIterator1.hasNext())
    {
      Callback localCallback = (Callback)localIterator1.next();
      if (localCallback.getEvent().toString().equals(str1))
      {
        Iterator localIterator2 = localCallback.getActions().iterator();
        while (localIterator2.hasNext())
        {
          CharSequence localCharSequence = (CharSequence)localIterator2.next();
          HashMap localHashMap = new HashMap();
          Object localObject = localCharSequence.toString();
          int i = ((String)localObject).indexOf('?');
          if (i != -1)
          {
            String str2 = ((String)localObject).substring(0, i);
            String str3 = ((String)localObject).substring(i + 1);
            if (str3.contains("%{eventParams}"))
            {
              str3 = str3.replace("%{eventParams}", "");
              localHashMap.putAll(paramgt.bj);
            }
            localHashMap.putAll(fl.H(str3));
            localObject = str2;
          }
          localArrayList.add(new y((String)localObject, localHashMap, paramgt));
        }
      }
    }
    return localArrayList;
  }

  private void a(SdkLogResponse paramSdkLogResponse)
  {
    try
    {
      if (paramSdkLogResponse.getResult().toString().equals("success"))
        this.hv.removeAll(this.hx);
      return;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  private void a(ca paramca, DataOutputStream paramDataOutputStream)
  {
    try
    {
      Iterator localIterator = paramca.ar().iterator();
      while (localIterator.hasNext())
      {
        bl localbl = (bl)localIterator.next();
        try
        {
          paramDataOutputStream.writeShort(1);
          localbl.a(paramDataOutputStream);
        }
        catch (IOException localIOException)
        {
          cy.c(p, "unable to convert freqCap to byte[]: " + localbl.ab());
        }
      }
    }
    finally
    {
    }
  }

  private boolean a(Context paramContext, String paramString, FlurryAdSize paramFlurryAdSize, long paramLong)
  {
    boolean bool2;
    if (c(paramContext, paramString))
      bool2 = true;
    while (true)
    {
      return bool2;
      bi localbi = new bi(this, paramContext, paramString, paramFlurryAdSize, null, false, false);
      localbi.execute(new Void[0]);
      try
      {
        localbi.get(paramLong, TimeUnit.MILLISECONDS);
        boolean bool1 = c(paramContext, paramString);
        bool2 = false;
        if (bool1)
          return true;
      }
      catch (InterruptedException localInterruptedException)
      {
        localInterruptedException.printStackTrace();
        return false;
      }
      catch (ExecutionException localExecutionException)
      {
        localExecutionException.printStackTrace();
        return false;
      }
      catch (TimeoutException localTimeoutException)
      {
      }
    }
    return false;
  }

  private boolean a(byte[] paramArrayOfByte, String paramString)
  {
    if (paramString == null)
      return false;
    StringBuilder localStringBuilder1;
    String str1;
    if (paramString.equals("/v6/getAds.do"))
    {
      localStringBuilder1 = new StringBuilder();
      if (this.hd != null)
        str1 = this.hd;
    }
    while (true)
    {
      String str2 = str1 + paramString;
      byte[] arrayOfByte = b(paramArrayOfByte, str2);
      if (arrayOfByte != null);
      try
      {
        if (paramString.equals("/postAdLog.do"))
          c(arrayOfByte);
        return true;
        if (FlurryAgent.getUseHttps())
        {
          str1 = "https://ads.flurry.com";
          continue;
        }
        str1 = "http://ads.flurry.com";
        continue;
        StringBuilder localStringBuilder2 = new StringBuilder();
        String str3;
        if (this.he != null)
          str3 = this.he;
        while (true)
        {
          str2 = str3 + paramString;
          break;
          if (FlurryAgent.getUseHttps())
            str3 = "https://adlog.flurry.com";
          else
            str3 = "http://adlog.flurry.com";
        }
      }
      catch (IOException localIOException)
      {
        while (true)
          cy.d(p, "IOException: " + localIOException.toString());
      }
    }
  }

  private static byte[] a(InputStream paramInputStream)
    throws IOException
  {
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
    byte[] arrayOfByte = new byte[''];
    while (true)
    {
      int i = paramInputStream.read(arrayOfByte);
      if (i == -1)
        break;
      localByteArrayOutputStream.write(arrayOfByte, 0, i);
    }
    return localByteArrayOutputStream.toByteArray();
  }

  private byte[] a(String paramString, int paramInt1, int paramInt2, int paramInt3, int paramInt4, boolean paramBoolean, FlurryAdSize paramFlurryAdSize, Context paramContext)
  {
    List localList = bn();
    ArrayList localArrayList = new ArrayList();
    Iterator localIterator = this.ho.ar().iterator();
    while (localIterator.hasNext())
    {
      bl localbl = (bl)localIterator.next();
      localArrayList.add(FrequencyCapInfo.bK().setIdHash(localbl.ab()).setExpirationTime(localbl.ah()).setNewCap(localbl.ae()).setPreviousCap(localbl.af()).setPreviousCapType(localbl.ag()).setServeTime(localbl.ai()).setViews(localbl.ac()).build());
    }
    AdRequest.Builder localBuilder1 = AdRequest.bt().setApiKey(FlurryAgent.y()).setAdSpaceName("").setBindings(gR).setAdReportedIds(localList);
    Location localLocation = this.hf;
    if (localLocation != null);
    while (true)
    {
      AdRequest.Builder localBuilder2 = localBuilder1.setLocation(localLocation).setTestDevice(this.hz).setAgentVersion(Integer.toString(FlurryAgent.getAgentVersion())).setSessionId(this.aL).setAdViewContainer(AdViewContainer.B().setScreenHeight(paramInt4).setScreenWidth(paramInt3).setViewHeight(paramInt2).setViewWidth(paramInt1).setDensity(paramContext.getResources().getDisplayMetrics().density).build()).setLocale(FlurryAgent.getLocale()).setTimezone(FlurryAgent.z()).setOsVersion(this.aC).setDevicePlatform(this.gZ).setCanDoSKAppStore(false);
      ConnectivityManager localConnectivityManager;
      gp localgp;
      label316: AdRequest localAdRequest;
      SpecificDatumWriter localSpecificDatumWriter;
      ByteArrayOutputStream localByteArrayOutputStream;
      BinaryEncoder localBinaryEncoder;
      if (paramContext.checkCallingOrSelfPermission("android.permission.ACCESS_NETWORK_STATE") == 0)
      {
        localConnectivityManager = (ConnectivityManager)paramContext.getSystemService("connectivity");
        NetworkInfo localNetworkInfo1 = localConnectivityManager.getNetworkInfo(1);
        if ((localNetworkInfo1 != null) && (localNetworkInfo1.isConnected()))
        {
          localgp = gp.iP;
          localAdRequest = localBuilder2.setNetworkStatus(localgp.getValue()).setFrequencyCapInfos(localArrayList).setPreferredLanguage(Locale.getDefault().getLanguage()).build();
          if (!paramBoolean)
            break label564;
          localAdRequest.a(Boolean.valueOf(paramBoolean));
          if (paramFlurryAdSize != null)
            localAdRequest.a(TestAds.bN().setAdspacePlacement(paramFlurryAdSize.getValue()).build());
          if (this.hA != null)
            localAdRequest.c(bj());
          new StringBuilder().append("Got ad request: ").append(localAdRequest).toString();
          localSpecificDatumWriter = new SpecificDatumWriter(AdRequest.class);
          localByteArrayOutputStream = new ByteArrayOutputStream();
          localBinaryEncoder = EncoderFactory.get().directBinaryEncoder(localByteArrayOutputStream, null);
        }
      }
      try
      {
        localSpecificDatumWriter.write(localAdRequest, localBinaryEncoder);
        localBinaryEncoder.flush();
        return localByteArrayOutputStream.toByteArray();
        android.location.Location localLocation1 = FlurryAgent.getLocation();
        float f1 = 0.0F;
        float f2 = 0.0F;
        if (localLocation1 != null)
        {
          f2 = (float)localLocation1.getLatitude();
          f1 = (float)localLocation1.getLongitude();
        }
        localLocation = Location.bS().setLat(f2).setLon(f1).build();
        continue;
        NetworkInfo localNetworkInfo2 = localConnectivityManager.getNetworkInfo(0);
        if ((localNetworkInfo2 != null) && (localNetworkInfo2.isConnected()))
        {
          localgp = gp.iQ;
          break label316;
        }
        localgp = gp.iO;
        break label316;
        label564: localAdRequest.c(paramString);
      }
      catch (IOException localIOException)
      {
        localIOException.getMessage();
      }
    }
    return new byte[0];
  }

  private static int b(byte[] paramArrayOfByte)
  {
    CrcMessageDigest localCrcMessageDigest = new CrcMessageDigest();
    localCrcMessageDigest.update(paramArrayOfByte);
    return localCrcMessageDigest.getChecksum();
  }

  private void b(Context paramContext, String paramString, ViewGroup paramViewGroup)
  {
    if (!o(paramContext))
      if (this.hs != null)
        this.hs.spaceDidFailToReceiveAd(paramString.toString());
    fm localfm;
    do
    {
      return;
      localfm = this.hn.P(paramString);
    }
    while (localfm == null);
    AdUnit localAdUnit = localfm.L();
    cw localcw = (cw)this.hw.get(((AdFrame)localAdUnit.getAdFrames().get(0)).getAdGuid().toString());
    onEvent(new gt("requested", Collections.emptyMap(), paramContext, localfm.L(), localcw, 0), this, 0);
    if (this.hs != null)
    {
      if (!(localfm instanceof ex))
        break label152;
      this.hs.shouldDisplayAd(paramString.toString(), FlurryAdType.WEB_BANNER);
    }
    while (true)
    {
      localfm.a(paramContext, paramViewGroup);
      return;
      label152: this.hs.shouldDisplayAd(paramString.toString(), FlurryAdType.WEB_TAKEOVER);
    }
  }

  private static boolean b(Context paramContext, String paramString1, String paramString2)
  {
    Intent localIntent = new Intent(paramString2);
    localIntent.setData(Uri.parse(paramString1));
    return fl.a(paramContext, localIntent);
  }

  private byte[] b(byte[] paramArrayOfByte, String paramString)
  {
    ByteArrayEntity localByteArrayEntity = new ByteArrayEntity(paramArrayOfByte);
    localByteArrayEntity.setContentType("avro/binary");
    HttpPost localHttpPost = new HttpPost(paramString);
    localHttpPost.setEntity(localByteArrayEntity);
    localHttpPost.setHeader("accept", "avro/binary");
    localHttpPost.setHeader("FM-Checksum", Integer.toString(b(paramArrayOfByte)));
    if (!TextUtils.isEmpty(this.hl))
      localHttpPost.setHeader("Device-UA", this.hl);
    BasicHttpParams localBasicHttpParams = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(localBasicHttpParams, 10000);
    HttpConnectionParams.setSoTimeout(localBasicHttpParams, 15000);
    localHttpPost.getParams().setBooleanParameter("http.protocol.expect-continue", false);
    HttpClient localHttpClient = ch.a(localBasicHttpParams);
    byte[] arrayOfByte;
    try
    {
      HttpResponse localHttpResponse = localHttpClient.execute(localHttpPost);
      int i = localHttpResponse.getStatusLine().getStatusCode();
      if ((i == 200) && (localHttpResponse.getEntity() != null) && (localHttpResponse.getEntity().getContentLength() != 0L))
      {
        cy.e(p, "Request successful");
        arrayOfByte = a(localHttpResponse.getEntity().getContent());
        localByteArrayEntity.consumeContent();
        String str = Integer.toString(b(arrayOfByte));
        if (!localHttpResponse.containsHeader("FM-Checksum"))
          break label349;
        if (localHttpResponse.getFirstHeader("FM-Checksum").getValue().equals(str))
          return arrayOfByte;
      }
      else
      {
        new StringBuilder().append("Request to url = ").append(paramString).append(" failed with HTTP = ").append(i).toString();
      }
      return null;
    }
    catch (IOException localIOException)
    {
      while (true)
        cy.a(6, p, "Request to url = " + paramString + " failed with IOException = " + localIOException.toString(), localIOException);
    }
    label349: return arrayOfByte;
  }

  private Map<CharSequence, CharSequence> bj()
  {
    HashMap localHashMap = new HashMap();
    Iterator localIterator = this.hA.entrySet().iterator();
    while (localIterator.hasNext())
    {
      Map.Entry localEntry = (Map.Entry)localIterator.next();
      String str1 = (String)localEntry.getKey();
      String str2 = (String)localEntry.getValue();
      if (str1 == null)
        str1 = "";
      if (str2 == null)
        str2 = "";
      localHashMap.put(str1, str2);
    }
    return localHashMap;
  }

  private void bl()
  {
    try
    {
      ci localci = new ci(this);
      this.hm.post(localci);
      return;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  private byte[] bm()
  {
    List localList1 = bn();
    SdkLogRequest localSdkLogRequest;
    SpecificDatumWriter localSpecificDatumWriter;
    ByteArrayOutputStream localByteArrayOutputStream;
    BinaryEncoder localBinaryEncoder;
    synchronized (this.hv)
    {
      List localList3 = gT.h(this.hv);
      if (localList3.size() == 0)
        return null;
      localSdkLogRequest = SdkLogRequest.X().setApiKey(FlurryAgent.y()).setAdReportedIds(localList1).setSdkAdLogs(localList3).setTestDevice(false).setAgentTimestamp(System.currentTimeMillis()).build();
      new StringBuilder().append("Got ad log request:").append(localSdkLogRequest.toString()).toString();
      localSpecificDatumWriter = new SpecificDatumWriter(SdkLogRequest.class);
      localByteArrayOutputStream = new ByteArrayOutputStream();
      localBinaryEncoder = EncoderFactory.get().directBinaryEncoder(localByteArrayOutputStream, null);
    }
    try
    {
      localSpecificDatumWriter.write(localSdkLogRequest, localBinaryEncoder);
      localBinaryEncoder.flush();
      return localByteArrayOutputStream.toByteArray();
      localObject = finally;
      throw localObject;
    }
    catch (IOException localIOException)
    {
      new StringBuilder().append("Error generating adlog request").append(localIOException.getMessage()).toString();
    }
    return null;
  }

  private List<AdReportedId> bn()
  {
    ArrayList localArrayList = new ArrayList();
    ByteBuffer localByteBuffer1 = ByteBuffer.wrap(FlurryAgent.getPhoneId().getBytes());
    localArrayList.add(AdReportedId.bO().setId(localByteBuffer1).setType(0).build());
    byte[] arrayOfByte = this.ha;
    if (arrayOfByte != null)
    {
      ByteBuffer localByteBuffer2 = ByteBuffer.wrap(arrayOfByte);
      localArrayList.add(AdReportedId.bO().setId(localByteBuffer2).setType(ReportedIdType.Sha1Imei.eS).build());
    }
    Iterator localIterator = this.aH.entrySet().iterator();
    while (localIterator.hasNext())
    {
      Map.Entry localEntry = (Map.Entry)localIterator.next();
      localArrayList.add(AdReportedId.bO().setId((ByteBuffer)localEntry.getValue()).setType(((ReportedIdType)localEntry.getKey()).eS).build());
    }
    return localArrayList;
  }

  private void bo()
  {
    try
    {
      new cj(this).execute(new Void[0]);
      return;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  private void bp()
  {
    try
    {
      new ck(this).execute(new Void[0]);
      return;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  private void c(byte[] paramArrayOfByte)
    throws IOException
  {
    SdkLogResponse localSdkLogResponse = (SdkLogResponse)a(paramArrayOfByte, SdkLogResponse.class);
    if (localSdkLogResponse != null)
    {
      new StringBuilder().append("Got ad log response: ").append(localSdkLogResponse).toString();
      if (!localSdkLogResponse.getResult().toString().equals("success"))
        break label58;
      a(localSdkLogResponse);
    }
    while (true)
    {
      return;
      label58: Iterator localIterator = localSdkLogResponse.getErrors().iterator();
      while (localIterator.hasNext())
      {
        CharSequence localCharSequence = (CharSequence)localIterator.next();
        cy.d(p, localCharSequence.toString());
      }
    }
  }

  private boolean c(Context paramContext, String paramString)
  {
    return this.hk.c(paramContext, paramString);
  }

  public static void clearLocation()
  {
    getInstance().hf = null;
  }

  public static void clearTargetingKeywords()
  {
    getInstance().hA = null;
  }

  public static void clearUserCookies()
  {
    getInstance().hg.clear();
  }

  public static void displayAd(Context paramContext, String paramString, ViewGroup paramViewGroup)
  {
    if (paramContext == null)
    {
      cy.d(p, "Context passed to displayAd was null.");
      return;
    }
    if (paramString == null)
    {
      cy.d(p, "Ad space name passed to displayAd was null.");
      return;
    }
    if (paramString.length() == 0)
    {
      cy.d(p, "Ad space name passed to displayAd was empty.");
      return;
    }
    if (paramViewGroup == null)
    {
      cy.d(p, "ViewGroup  passed to displayAd was null.");
      return;
    }
    getInstance().m(paramContext);
    try
    {
      hF.b(paramContext, paramString, paramViewGroup);
      return;
    }
    catch (Throwable localThrowable)
    {
      cy.b(p, "", localThrowable);
    }
  }

  public static void enableTestAds(boolean paramBoolean)
  {
    getInstance().hz = paramBoolean;
  }

  public static void fetchAd(Context paramContext, String paramString, ViewGroup paramViewGroup, FlurryAdSize paramFlurryAdSize)
  {
    if (paramContext == null)
      cy.d(p, "Context passed to fetchAd was null.");
    FlurryAds localFlurryAds;
    do
    {
      while (true)
      {
        return;
        if (paramString == null)
        {
          cy.d(p, "Ad space name passed to fetchAd was null.");
          return;
        }
        if (paramString.length() == 0)
        {
          cy.d(p, "Ad space name passed to fetchAd was empty.");
          return;
        }
        if (paramViewGroup == null)
        {
          cy.d(p, "ViewGroup passed to fetchAd was null.");
          return;
        }
        if (paramFlurryAdSize == null)
        {
          cy.d(p, "FlurryAdSize passed to fetchAd was null.");
          return;
        }
        getInstance().m(paramContext);
        try
        {
          localFlurryAds = hF;
          if (!o(paramContext))
          {
            if (localFlurryAds.hs == null)
              continue;
            localFlurryAds.hs.spaceDidFailToReceiveAd(paramString.toString());
          }
        }
        catch (Throwable localThrowable)
        {
          cy.b(p, "", localThrowable);
          return;
        }
      }
      if ((localFlurryAds.c(paramContext, paramString)) && (!n(paramContext)))
      {
        localFlurryAds.g(paramContext, paramString);
        return;
      }
    }
    while (n(paramContext));
    new bi(localFlurryAds, paramContext, paramString, paramFlurryAdSize, paramViewGroup, true, false).execute(new Void[0]);
  }

  public static boolean getAd(Context paramContext, String paramString, ViewGroup paramViewGroup, FlurryAdSize paramFlurryAdSize, long paramLong)
  {
    if (paramContext == null)
    {
      cy.d(p, "Context passed to getAd was null.");
      return false;
    }
    if (paramString == null)
    {
      cy.d(p, "Ad space name passed to getAd was null.");
      return false;
    }
    if (paramString.length() == 0)
    {
      cy.d(p, "Ad space name passed to getAd was empty.");
      return false;
    }
    if (paramViewGroup == null)
    {
      cy.d(p, "ViewGroup passed to getAd was null.");
      return false;
    }
    if (paramFlurryAdSize == null)
    {
      cy.d(p, "FlurryAdSize passed to getAd was null.");
      return false;
    }
    getInstance().m(paramContext);
    try
    {
      boolean bool = hF.a(paramContext, paramString, paramFlurryAdSize, paramViewGroup, paramLong);
      return bool;
    }
    catch (Throwable localThrowable)
    {
      cy.b(p, "", localThrowable);
    }
    return false;
  }

  static FlurryAds getInstance()
  {
    if (hF == null)
      hF = new FlurryAds();
    return hF;
  }

  static String getPhoneId()
  {
    return FlurryAgent.getPhoneId();
  }

  static boolean i(Context paramContext, String paramString)
  {
    int i = 0;
    while (true)
      if (i < 5)
      {
        if ((o(paramContext) == true) && (!n(paramContext)))
        {
          HttpResponse localHttpResponse = fl.a(paramString, 10000, 15000, true);
          if ((localHttpResponse == null) || (localHttpResponse.getStatusLine().getStatusCode() != 200))
            break label87;
          new StringBuilder().append("URL hit succeeded for: ").append(paramString).toString();
          return true;
        }
        try
        {
          Thread.sleep(100L);
          label87: i++;
        }
        catch (InterruptedException localInterruptedException)
        {
          while (true)
            localInterruptedException.getMessage();
        }
      }
    return false;
  }

  public static void initializeAds(Context paramContext)
  {
    if (paramContext == null)
    {
      cy.d(p, "Context passed to initializeAds was null.");
      return;
    }
    getInstance().m(paramContext);
    try
    {
      hF.p(paramContext);
      return;
    }
    catch (Throwable localThrowable)
    {
      cy.b(p, "", localThrowable);
    }
  }

  public static boolean isAdAvailable(Context paramContext, String paramString, FlurryAdSize paramFlurryAdSize, long paramLong)
  {
    if (paramContext == null)
    {
      cy.d(p, "Context passed to isAdAvailable was null.");
      return false;
    }
    if (paramString == null)
    {
      cy.d(p, "Ad space name passed to isAdAvailable was null.");
      return false;
    }
    if (paramString.length() == 0)
    {
      cy.d(p, "Ad space name passed to isAdAvailable was empty.");
      return false;
    }
    if (paramFlurryAdSize == null)
    {
      cy.d(p, "FlurryAdSize passed to isAdAvailable was null.");
      return false;
    }
    getInstance().m(paramContext);
    try
    {
      boolean bool = hF.a(paramContext, paramString, paramFlurryAdSize, paramLong);
      return bool;
    }
    catch (Throwable localThrowable)
    {
      cy.b(p, "", localThrowable);
    }
    return false;
  }

  public static boolean isAdReady(String paramString)
  {
    if (paramString == null)
    {
      cy.d(p, "Ad space name passed to isAdReady was null.");
      return false;
    }
    if (paramString.length() == 0)
    {
      cy.d(p, "Ad space name passed to isAdReady was empty.");
      return false;
    }
    return getInstance().hn.Q(paramString);
  }

  private AdUnit j(Context paramContext, String paramString)
  {
    return this.hk.b(paramContext, paramString);
  }

  private void m(Context paramContext)
  {
    try
    {
      if (!this.hG)
      {
        this.gX = paramContext.getFileStreamPath(".flurryadlog." + Integer.toString(FlurryAgent.y().hashCode(), 16));
        this.gY = paramContext.getFileStreamPath(".flurryfreqcap." + Integer.toString(FlurryAgent.y().hashCode(), 16));
        String str = paramContext.getPackageName();
        this.hb = b(paramContext, "market://details?id=" + str, "android.intent.action.VIEW");
        this.hl = "";
        this.ha = FlurryAgent.an.fetchHashedImei(paramContext);
        bo();
        cy.c(p, "Attempting to load FreqCap data");
        bp();
        this.hG = true;
      }
      return;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  static boolean n(Context paramContext)
  {
    return ((KeyguardManager)paramContext.getSystemService("keyguard")).inKeyguardRestrictedInputMode();
  }

  private static boolean o(Context paramContext)
  {
    boolean bool;
    if (paramContext.checkCallingOrSelfPermission("android.permission.ACCESS_NETWORK_STATE") != 0)
      bool = true;
    while (true)
    {
      return bool;
      NetworkInfo localNetworkInfo = ((ConnectivityManager)paramContext.getSystemService("connectivity")).getActiveNetworkInfo();
      if ((localNetworkInfo != null) && ((localNetworkInfo.isConnected()) || (localNetworkInfo.isRoaming())));
      for (bool = true; !bool; bool = false)
      {
        cy.g(p, "No connectivity found.");
        return bool;
      }
    }
  }

  private void p(Context paramContext)
  {
    try
    {
      if (!this.hc)
      {
        cy.e(p, "Initializing ads -- requesting ads with precaching enabled on the server");
        boolean bool = FlurryAgent.p();
        int i = 0;
        if (!bool)
          i = 500;
        this.hm.postDelayed(new cm(this, paramContext), i);
        this.hc = true;
      }
      while (true)
      {
        return;
        cy.e(p, "Initializing ads -- not making a new ad request (for ads with precaching enabled on the server) since one was made already this session");
      }
    }
    finally
    {
    }
  }

  public static void removeAd(Context paramContext, String paramString, ViewGroup paramViewGroup)
  {
    if (paramContext == null)
    {
      cy.d(p, "Context passed to removeAd was null.");
      return;
    }
    if (paramString == null)
    {
      cy.d(p, "Ad space name passed to removeAd was null.");
      return;
    }
    if (paramString.length() == 0)
    {
      cy.d(p, "Ad space name passed to removeAd was empty.");
      return;
    }
    if (paramViewGroup == null)
    {
      cy.d(p, "ViewGroup passed to removeAd was null.");
      return;
    }
    getInstance().m(paramContext);
    FlurryAds localFlurryAds;
    v localv;
    try
    {
      localFlurryAds = hF;
      new StringBuilder().append("_removeAd(context = ").append(paramContext).append(", adSpaceName = ").append(paramString).append(")").toString();
      localv = localFlurryAds.hn.O(paramString);
      if (localv == null)
      {
        localFlurryAds.C(paramString);
        return;
      }
    }
    catch (Throwable localThrowable)
    {
      cy.b(p, "", localThrowable);
      return;
    }
    localv.stop();
    ViewGroup localViewGroup = localv.h();
    if (localViewGroup != null)
    {
      localv.removeAllViews();
      localViewGroup.removeView(localv);
    }
    localFlurryAds.C(paramString);
    localFlurryAds.hn.d(localv);
  }

  public static void setAdListener(FlurryAdListener paramFlurryAdListener)
  {
    getInstance().hs = paramFlurryAdListener;
  }

  public static void setAdLogUrl(String paramString)
  {
    getInstance().he = paramString;
  }

  public static void setAdServerUrl(String paramString)
  {
    getInstance().hd = paramString;
  }

  public static void setCustomAdNetworkHandler(ICustomAdNetworkHandler paramICustomAdNetworkHandler)
  {
    if (paramICustomAdNetworkHandler == null)
    {
      cy.d(p, "ICustomAdNetworkHandler passed to setCustomAdNetworkHandler was null.");
      return;
    }
    getInstance().hp = paramICustomAdNetworkHandler;
  }

  public static void setLocation(float paramFloat1, float paramFloat2)
  {
    getInstance().hf = Location.bS().setLat(paramFloat1).setLon(paramFloat2).build();
  }

  public static void setTargetingKeywords(Map<String, String> paramMap)
  {
    if (paramMap == null)
      cy.d(p, "targetingKeywords Map passed to setTargetingKeywords was null.");
    while (paramMap == null)
      return;
    getInstance().hA = paramMap;
  }

  public static void setUserCookies(Map<String, String> paramMap)
  {
    if (paramMap == null)
      cy.d(p, "userCookies Map passed to setUserCookies was null.");
    while (true)
    {
      return;
      FlurryAds localFlurryAds = getInstance();
      if ((paramMap != null) && (paramMap.size() > 0))
      {
        Iterator localIterator = paramMap.entrySet().iterator();
        while (localIterator.hasNext())
        {
          Map.Entry localEntry = (Map.Entry)localIterator.next();
          if ((localEntry.getKey() != null) && (localEntry.getValue() != null))
            localFlurryAds.hg.put(localEntry.getKey(), localEntry.getValue());
          else
            cy.g(p, "User cookie keys and values may not be null.");
        }
      }
    }
  }

  static String y()
  {
    return FlurryAgent.y();
  }

  final void B(String paramString)
  {
    byte[] arrayOfByte = bm();
    if (arrayOfByte != null)
      a(arrayOfByte, paramString);
  }

  final List<AdUnit> a(Context paramContext, String paramString, ViewGroup paramViewGroup, boolean paramBoolean, FlurryAdSize paramFlurryAdSize)
  {
    this.ho.as();
    if (Build.VERSION.SDK_INT >= 9)
    {
      int i = fl.s(paramContext);
      int j = fl.t(paramContext);
      switch (fl.u(paramContext))
      {
      default:
      case 2:
      }
      byte[] arrayOfByte1;
      for (Pair localPair1 = Pair.create(Integer.valueOf(i), Integer.valueOf(j)); ; localPair1 = Pair.create(Integer.valueOf(j), Integer.valueOf(i)))
      {
        int k = ((Integer)localPair1.first).intValue();
        int m = ((Integer)localPair1.second).intValue();
        Pair localPair2 = Pair.create(Integer.valueOf(fl.s(paramContext)), Integer.valueOf(fl.t(paramContext)));
        int n = ((Integer)localPair2.first).intValue();
        int i1 = ((Integer)localPair2.second).intValue();
        if ((paramFlurryAdSize.equals(FlurryAdSize.BANNER_BOTTOM)) || (paramFlurryAdSize.equals(FlurryAdSize.BANNER_TOP)))
        {
          if ((paramViewGroup != null) && (paramViewGroup.getHeight() > 0))
            i1 = fl.a(paramContext, paramViewGroup.getHeight());
          if ((paramViewGroup != null) && (paramViewGroup.getWidth() > 0))
            n = fl.a(paramContext, paramViewGroup.getWidth());
        }
        arrayOfByte1 = a(paramString, n, i1, k, m, paramBoolean, paramFlurryAdSize, paramContext);
        if ((arrayOfByte1 != null) && (arrayOfByte1.length >= 1))
          break;
        return Collections.emptyList();
      }
      String str;
      if (this.hd != null)
        str = this.hd + "/v6/getAds.do";
      byte[] arrayOfByte2;
      while (true)
      {
        arrayOfByte2 = b(arrayOfByte1, str);
        if ((arrayOfByte2 != null) && (arrayOfByte2.length >= 1))
          break;
        return Collections.emptyList();
        if (FlurryAgent.getUseHttps())
          str = "https://ads.flurry.com/v6/getAds.do";
        else
          str = "http://ads.flurry.com/v6/getAds.do";
      }
      AdResponse localAdResponse = (AdResponse)a(arrayOfByte2, AdResponse.class);
      if (localAdResponse == null)
        return Collections.emptyList();
      new StringBuilder().append("Got ad response: ").append(localAdResponse).toString();
      if (localAdResponse.getErrors().size() > 0)
      {
        cy.d(p, "Ad server responded with the following error(s):");
        Iterator localIterator = localAdResponse.getErrors().iterator();
        while (localIterator.hasNext())
        {
          CharSequence localCharSequence = (CharSequence)localIterator.next();
          cy.d(p, localCharSequence.toString());
        }
        return Collections.emptyList();
      }
      if ((!TextUtils.isEmpty(paramString)) && ((localAdResponse.getAdUnits() == null) || (localAdResponse.getAdUnits().size() == 0)))
      {
        cy.d(p, "Ad server responded but sent no ad units.");
        return Collections.emptyList();
      }
      return localAdResponse.getAdUnits();
    }
    return null;
  }

  final void a(Activity paramActivity)
  {
    if (paramActivity == null);
    while (true)
    {
      return;
      this.hu.add(paramActivity);
      Intent localIntent1 = paramActivity.getIntent();
      String str = a(localIntent1);
      onOpenFullScreen(paramActivity, str);
      if (localIntent1 == null);
      for (Intent localIntent2 = null; (localIntent2 != null) && (this.hs != null); localIntent2 = (Intent)localIntent1.getParcelableExtra("targetIntent"))
      {
        this.hs.onApplicationExit(str);
        return;
      }
    }
  }

  final void a(Context paramContext, String paramString, boolean paramBoolean, AdUnit paramAdUnit)
  {
    this.hm.post(new cr(this, paramString, paramAdUnit, paramContext, paramBoolean));
  }

  final void a(AdUnit paramAdUnit)
  {
    this.hi = paramAdUnit;
  }

  final void a(cw paramcw)
  {
    try
    {
      if (this.hv.size() < 32767)
      {
        this.hv.add(paramcw);
        this.hw.put(paramcw.aA(), paramcw);
      }
      return;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  final void a(DataInputStream paramDataInputStream)
    throws IOException
  {
    try
    {
      while (paramDataInputStream.readShort() != 0)
        synchronized (this.ho)
        {
          this.ho.a(new bl(paramDataInputStream));
        }
    }
    finally
    {
    }
    this.gW = true;
  }

  final boolean a(Context paramContext, Intent paramIntent, String paramString)
  {
    boolean bool1 = false;
    ComponentName localComponentName;
    if (paramContext != null)
    {
      bool1 = false;
      if (paramIntent != null)
      {
        bool1 = false;
        if (paramString != null)
        {
          boolean bool2 = fl.a(paramContext, paramIntent);
          bool1 = false;
          if (bool2)
          {
            if ((paramContext == null) || (paramIntent == null))
              break label151;
            localComponentName = paramIntent.resolveActivity(paramContext.getPackageManager());
          }
        }
      }
    }
    label151: for (boolean bool3 = paramContext.getPackageName().equals(localComponentName.getPackageName()); ; bool3 = false)
    {
      Intent localIntent;
      if (bool3)
        localIntent = new Intent(paramIntent);
      while (true)
      {
        if (localIntent != null)
          localIntent.putExtra("adSpaceName", paramString);
        try
        {
          paramContext.startActivity(localIntent);
          bool1 = true;
          return bool1;
          localIntent = new Intent(paramContext, FlurryFullscreenTakeoverActivity.class);
          localIntent.putExtra("targetIntent", paramIntent);
        }
        catch (ActivityNotFoundException localActivityNotFoundException)
        {
          cy.b(p, "Cannot launch Activity", localActivityNotFoundException);
          return false;
        }
      }
    }
  }

  final boolean a(Context paramContext, String paramString, ViewGroup paramViewGroup)
  {
    if (!g(paramContext, paramString))
      return false;
    b(paramContext, paramString, paramViewGroup);
    return true;
  }

  final boolean a(Context paramContext, String paramString, FlurryAdSize paramFlurryAdSize, ViewGroup paramViewGroup, long paramLong)
  {
    if (!c(paramContext, paramString))
    {
      if ((o(paramContext)) && (!n(paramContext)))
      {
        boolean bool1;
        if (paramLong == 0L)
          bool1 = true;
        while (true)
        {
          boolean bool2;
          bi localbi;
          if (paramLong == 0L)
          {
            bool2 = true;
            localbi = new bi(this, paramContext, paramString, paramFlurryAdSize, paramViewGroup, bool1, bool2);
            localbi.execute(new Void[0]);
            if (paramLong <= 0L)
              break label173;
          }
          try
          {
            localbi.get(paramLong, TimeUnit.MILLISECONDS);
            if (!c(paramContext, paramString))
              break label173;
            boolean bool3 = a(paramContext, paramString, paramViewGroup);
            return bool3;
            bool1 = false;
            continue;
            bool2 = false;
          }
          catch (InterruptedException localInterruptedException)
          {
            localInterruptedException.printStackTrace();
            return false;
          }
          catch (ExecutionException localExecutionException)
          {
            localExecutionException.printStackTrace();
            return false;
          }
          catch (TimeoutException localTimeoutException)
          {
            return false;
          }
        }
      }
      if ((!o(paramContext)) && (this.hs != null))
        this.hs.spaceDidFailToReceiveAd(paramString.toString());
      label173: return false;
    }
    if (!n(paramContext))
      return a(paramContext, paramString, paramViewGroup);
    return false;
  }

  final long aJ()
  {
    return this.aL;
  }

  final void b(Activity paramActivity)
  {
    if (paramActivity == null);
    while (true)
    {
      return;
      onCloseFullScreen(paramActivity, a(paramActivity.getIntent()));
      this.hu.remove(paramActivity);
      if (1 == this.hu.size())
      {
        Activity localActivity = (Activity)this.hu.get(0);
        AdUnit localAdUnit2;
        int i;
        AdUnit localAdUnit1;
        if ((localActivity instanceof FlurryFullscreenTakeoverActivity))
        {
          FlurryFullscreenTakeoverActivity localFlurryFullscreenTakeoverActivity = (FlurryFullscreenTakeoverActivity)localActivity;
          localAdUnit2 = localFlurryFullscreenTakeoverActivity.L();
          ft localft = localFlurryFullscreenTakeoverActivity.aH();
          if (localft != null)
          {
            i = localft.U;
            localAdUnit1 = localAdUnit2;
          }
        }
        while ((localAdUnit1 != null) && ((localAdUnit1.getCombinable().intValue() != 1) || (i > 0)))
        {
          localActivity.finish();
          return;
          localAdUnit1 = localAdUnit2;
          i = 0;
          continue;
          i = 0;
          localAdUnit1 = null;
        }
      }
    }
  }

  final void b(Context paramContext, List<AdUnit> paramList)
  {
    this.hk.a(paramContext, paramList);
  }

  final void b(cw paramcw)
  {
    this.hh = paramcw;
  }

  final boolean bg()
  {
    return this.ht != 0;
  }

  final long bh()
  {
    try
    {
      long l1 = SystemClock.elapsedRealtime() - this.aM;
      if (l1 > this.hj);
      while (true)
      {
        this.hj = l1;
        long l2 = this.hj;
        return l2;
        l1 = 1L + this.hj;
        this.hj = l1;
      }
    }
    finally
    {
    }
  }

  final Map<ReportedIdType, ByteBuffer> bi()
  {
    return this.aH;
  }

  final Map<String, String> bk()
  {
    Map localMap = this.hg;
    dz localdz;
    if (this.hH != null)
    {
      localdz = this.hH;
      if (localdz.mContext != null)
        break label48;
    }
    label48: for (String str = ""; ; str = localdz.mContext.getSharedPreferences("FLURRY_SHARED_PREFERENCES", 0).getString("flurry_last_user_id", ""))
    {
      if (!TextUtils.isEmpty(str))
        localMap.put("appCloudUserId", str);
      return localMap;
    }
  }

  final cw bq()
  {
    return this.hh;
  }

  final AdUnit br()
  {
    return this.hi;
  }

  final boolean c(Context paramContext, String paramString1, String paramString2)
  {
    return a(paramContext, new Intent("android.intent.action.VIEW").setData(Uri.parse(paramString1)), paramString2);
  }

  public void cleanUpSession(Context paramContext)
  {
    Iterator localIterator = this.hn.w(paramContext).iterator();
    while (localIterator.hasNext())
    {
      v localv = (v)localIterator.next();
      localv.stop();
      localv.removeAllViews();
      ViewGroup localViewGroup = localv.h();
      if (localViewGroup != null)
        localViewGroup.removeView(localv);
      this.hn.d(localv);
    }
  }

  final void d(Context paramContext, String paramString1, String paramString2)
  {
    if (paramString1.startsWith("market://details?id="))
    {
      if (this.hb)
      {
        if (!c(paramContext, paramString1, paramString2))
          cy.d(p, "Cannot launch Google Play url " + paramString1);
        return;
      }
      String str = paramString1.substring("market://details?id=".length());
      c(paramContext, "https://market.android.com/details?id=" + str, paramString2);
      return;
    }
    cy.g(p, "Unexpected Google Play url scheme: " + paramString1);
  }

  final boolean g(Context paramContext, String paramString)
  {
    boolean bool = true;
    AdUnit localAdUnit = j(paramContext, paramString);
    if (localAdUnit == null)
    {
      a(ct.a(this, null), "unfilled", bool, null);
      if (this.hs != null)
        this.hs.spaceDidFailToReceiveAd(paramString.toString());
      bool = false;
    }
    do
    {
      return bool;
      this.hC = null;
      fm localfm = a(paramContext, localAdUnit);
      this.hn.a(paramString, localfm);
    }
    while (this.hs == null);
    this.hs.spaceDidReceiveAd(paramString.toString());
    return bool;
  }

  final String h(Context paramContext, String paramString)
  {
    int i = 0;
    String str = paramString;
    if (i < 5)
    {
      if (Uri.parse(str).getScheme().equals("http"))
        if ((o(paramContext) == true) && (!n(paramContext)))
        {
          localHttpResponse = fl.a(str, 10000, 15000, false);
          if (localHttpResponse != null)
          {
            j = localHttpResponse.getStatusLine().getStatusCode();
            if (j == 200)
              new StringBuilder().append("Redirect URL found for: ").append(str).toString();
          }
        }
      while ((b(paramContext, str, "android.intent.action.VIEW")) || ((!TextUtils.isEmpty(str)) && (str.startsWith("market://"))))
      {
        HttpResponse localHttpResponse;
        int j;
        return str;
        if ((j >= 300) && (j < 400))
        {
          new StringBuilder().append("NumRedirects: ").append(i + 1).toString();
          if (localHttpResponse.containsHeader("Location"))
            str = localHttpResponse.getFirstHeader("Location").getValue();
        }
        while (true)
        {
          i++;
          break;
          new StringBuilder().append("Bad Response status code: ").append(j).toString();
          return null;
          try
          {
            Thread.sleep(100L);
          }
          catch (InterruptedException localInterruptedException)
          {
            localInterruptedException.getMessage();
          }
        }
      }
    }
    return null;
  }

  final void i(List<cw> paramList)
  {
    this.hx = paramList;
  }

  public void onCloseFullScreen(Context paramContext, String paramString)
  {
    this.ht = (-1 + this.ht);
    if ((this.ht == 0) && (this.hs != null))
      this.hs.onAdClosed(paramString);
  }

  public void onContinueSession(Context paramContext)
  {
    this.ho.as();
  }

  public void onEndSession(Context paramContext)
  {
    bl();
  }

  public void onEvent(gt paramgt, au paramau, int paramInt)
  {
    new StringBuilder().append("onEvent:event=").append(paramgt.jf).append(",params=").append(paramgt.bj).toString();
    List localList = a((AdFrame)paramgt.T.getAdFrames().get(paramgt.jg), paramgt);
    if (localList.isEmpty())
    {
      Iterator localIterator4 = this.hD.entrySet().iterator();
      while (localIterator4.hasNext())
      {
        Map.Entry localEntry2 = (Map.Entry)localIterator4.next();
        if (((String)localEntry2.getKey()).equals(paramgt.jf))
          localList.add(new y((String)localEntry2.getValue(), paramgt.bj, paramgt));
      }
    }
    if (paramgt.jf.equals("adWillClose"))
    {
      Iterator localIterator3 = localList.iterator();
      y localy3;
      do
      {
        if (!localIterator3.hasNext())
          break;
        localy3 = (y)localIterator3.next();
      }
      while (!this.hE.contains(localy3.bi));
    }
    for (int i = 1; ; i = 0)
    {
      if (i == 0)
        localList.add(0, new y("closeAd", Collections.emptyMap(), paramgt));
      if ((paramgt.jf.equals("renderFailed")) && (this.hs != null))
        this.hs.onRenderFailed(paramgt.T.getAdSpace().toString());
      if ((paramgt.jf.equals("clicked")) && (this.hs != null))
        this.hs.onAdClicked(paramgt.T.getAdSpace().toString());
      if ((paramgt.jf.equals("videoCompleted")) && (this.hs != null))
        this.hs.onVideoCompleted(paramgt.T.getAdSpace().toString());
      Iterator localIterator1 = localList.iterator();
      Object localObject1 = null;
      y localy2;
      if (localIterator1.hasNext())
      {
        localy2 = (y)localIterator1.next();
        if (!localy2.bi.equals("logEvent"))
          break label632;
        localy2.bj.put("__sendToServer", "true");
      }
      label632: for (Object localObject2 = localy2; ; localObject2 = localObject1)
      {
        if (localy2.bi.equals("loadAdComponents"))
        {
          Iterator localIterator2 = localy2.bk.bj.entrySet().iterator();
          while (localIterator2.hasNext())
          {
            Map.Entry localEntry1 = (Map.Entry)localIterator2.next();
            localy2.bj.put(((String)localEntry1.getKey()).toString(), ((String)localEntry1.getValue()).toString());
          }
        }
        cy.f(p, localy2.toString());
        paramau.performAction$3deb3ec3(localy2, this, paramInt + 1);
        localObject1 = localObject2;
        break;
        if (localObject1 == null)
        {
          HashMap localHashMap = new HashMap();
          localHashMap.put("__sendToServer", "false");
          y localy1 = new y("logEvent", localHashMap, paramgt);
          paramau.performAction$3deb3ec3(localy1, this, paramInt + 1);
          cy.f(p, localy1.toString());
        }
        return;
      }
    }
  }

  public void onOpenFullScreen(Context paramContext, String paramString)
  {
    this.ht = (1 + this.ht);
    if ((1 == this.ht) && (this.hs != null))
      this.hs.onAdOpened(paramString);
  }

  public void onStartNewSession(Context paramContext, long paramLong1, long paramLong2)
  {
    this.hH = new dz(paramContext);
    this.aL = paramLong1;
    this.aM = paramLong2;
    this.hj = 0L;
    this.hc = false;
  }

  public void performAction$3deb3ec3(y paramy, FlurryAds paramFlurryAds, int paramInt)
  {
    new StringBuilder().append("performAction:action=").append(paramy.bi).append(",params=").append(paramy.bj).append(",triggering event=").append(paramy.bk.jf).toString();
    String str1 = paramy.bi;
    Context localContext = paramy.bk.Q;
    cw localcw = paramy.bk.S;
    AdUnit localAdUnit = paramy.bk.T;
    String str2 = localAdUnit.getAdSpace().toString();
    if (paramInt > 10)
      new StringBuilder().append("Maximum depth for event/action loop exceeded when performing action:").append(str1).append(",").append(paramy.bj).append(",triggered by:").append(paramy.bk.jf).toString();
    label773: bl localbl1;
    do
    {
      do
      {
        do
        {
          do
          {
            do
            {
              do
              {
                do
                {
                  do
                  {
                    do
                    {
                      do
                      {
                        return;
                        if (str1.equals("directOpen"))
                        {
                          if (paramy.bj.containsKey("url"))
                          {
                            String str14 = (String)paramy.bj.get("url");
                            if (str14.startsWith("market://"))
                            {
                              d(localContext, str14, str2);
                              return;
                            }
                            if ("true".equals(paramy.bj.get("native")))
                            {
                              c(localContext, a(localcw, localAdUnit, paramy, str14), str2);
                              return;
                            }
                            Intent localIntent3 = new Intent(localContext, FlurryFullscreenTakeoverActivity.class);
                            localIntent3.putExtra("url", str14);
                            if (fl.a(localContext, localIntent3))
                            {
                              a(localContext, localIntent3, str2);
                              return;
                            }
                            cy.g(p, "Can't start FlurryFullscreenTakeoverActivity, was it declared in the manifest? Falling back to default browser");
                            c(localContext, str14, str2);
                            return;
                          }
                          cy.d(p, "failed to perform directOpen action: no url in " + paramy.bk.jf);
                          return;
                        }
                        if (!str1.equals("delete"))
                          break;
                        if (paramy.bj.containsKey("count"))
                        {
                          String str13 = (String)paramy.bj.get("count");
                          try
                          {
                            int m = Integer.parseInt(str13);
                            k = m;
                            this.hk.a(localContext, str2, k);
                            return;
                          }
                          catch (NumberFormatException localNumberFormatException2)
                          {
                            while (true)
                            {
                              new StringBuilder().append("caught NumberFormatException with count parameter in deleteAds:").append(str13).toString();
                              int k = -1;
                            }
                          }
                        }
                      }
                      while (!paramy.bj.containsKey("groupId"));
                      String str12 = (String)paramy.bj.get("groupId");
                      this.hk.a(localContext, str2, str12);
                      return;
                      if (!str1.equals("processRedirect"))
                        break;
                    }
                    while (!paramy.bj.containsKey("url"));
                    String str10 = (String)paramy.bj.get("url");
                    if ("true".equals(paramy.bj.get("native")))
                    {
                      c(localContext, a(localcw, localAdUnit, paramy, str10), str2);
                      return;
                    }
                    if (str10.startsWith("http"))
                    {
                      String str11 = a(localcw, localAdUnit, paramy, str10);
                      this.hm.post(new cq(this, localContext, str11, true, localAdUnit));
                      return;
                    }
                    a(localContext, str10, false, localAdUnit);
                    return;
                    if (!str1.equals("verifyUrl"))
                      break;
                  }
                  while (!paramy.bj.containsKey("url"));
                  String str8 = (String)paramy.bj.get("url");
                  Intent localIntent2 = localContext.getPackageManager().getLaunchIntentForPackage(str8);
                  int j;
                  if ((localIntent2 != null) && (fl.a(localContext, localIntent2)))
                  {
                    j = 1;
                    if (j == 0)
                      break label773;
                  }
                  for (String str9 = "urlVerified"; ; str9 = "urlNotVerified")
                  {
                    paramFlurryAds.onEvent(new gt(str9, Collections.emptyMap(), localContext, localAdUnit, localcw, paramy.bk.jg), this, paramInt + 1);
                    return;
                    j = 0;
                    break;
                  }
                  if (!str1.equals("launchPackage"))
                    break;
                }
                while (!paramy.bj.containsKey("package"));
                String str7 = (String)paramy.bj.get("package");
                Intent localIntent1 = localContext.getPackageManager().getLaunchIntentForPackage(str7);
                if ((localIntent1 != null) && (fl.a(localContext, localIntent1)))
                {
                  a(localContext, localIntent1, localAdUnit.getAdSpace().toString());
                  return;
                }
                a(localContext, "https://play.google.com/store/apps/details?id=" + str7, false, localAdUnit);
                return;
                if (!str1.equals("sendUrlAsync"))
                  break;
              }
              while (!paramy.bj.containsKey("url"));
              String str6 = a(localcw, localAdUnit, paramy, (String)paramy.bj.get("url"));
              new StringBuilder().append("url after is: ").append(str6).toString();
              cp localcp = new cp(this, localContext, str6);
              this.hm.post(localcp);
              return;
              if (str1.equals("sendAdLogs"))
              {
                bl();
                return;
              }
              if (str1.equals("logEvent"))
              {
                if ((paramy.bj.containsKey("__sendToServer")) && (((String)paramy.bj.get("__sendToServer")).equals("true")));
                for (boolean bool2 = true; ; bool2 = false)
                {
                  paramy.bj.remove("__sendToServer");
                  a(paramy.bk.S, paramy.bk.jf, bool2, paramy.bj);
                  return;
                }
              }
            }
            while (str1.equals("nextFrame"));
            if (str1.equals("nextAdUnit"))
            {
              v localv = this.hn.O(str2);
              if ((localv != null) && (paramy.bj.containsKey("delay")))
              {
                int i = paramy.bk.jg;
                boolean bool1;
                if ((localAdUnit != null) && (localAdUnit.getAdFrames().size() > 0))
                  bool1 = ((AdFrame)localAdUnit.getAdFrames().get(i)).getAdSpaceLayout().getFormat().toString().equals("banner");
                while (true)
                  if (bool1)
                    try
                    {
                      long l2 = Long.parseLong((String)paramy.bj.get("delay"));
                      l1 = l2;
                      localv.a(l1 * 1000L);
                      return;
                      bool1 = false;
                    }
                    catch (NumberFormatException localNumberFormatException1)
                    {
                      while (true)
                      {
                        new StringBuilder().append("caught NumberFormatException with delay parameter in nextAdUnit:").append((String)paramy.bj.get("delay")).toString();
                        long l1 = 30L;
                      }
                    }
              }
              if (localv != null)
              {
                localv.post(new cl(this, localContext, str2, localv));
                return;
              }
              if (paramy.bk.jf.equals("renderFailed"))
              {
                g(localContext, str2);
                return;
              }
              this.hB = j(localContext, str2);
              a(localContext, this.hB);
              return;
            }
            if (!str1.equals("checkCap"))
              break;
          }
          while (!paramy.bj.containsKey("idHash"));
          String str4 = (String)paramy.bj.get("idHash");
          bl localbl2 = this.ho.l(str4);
          String str5 = "capNotExhausted";
          if ((localbl2 != null) && (ca.c(localbl2.ah())))
          {
            cy.f(p, "Discarding expired frequency cap info for idHash=" + str4);
            this.ho.m(str4);
            localbl2 = null;
          }
          if ((localbl2 != null) && (localbl2.ac() >= localbl2.ae()))
          {
            cy.f(p, "Frequency cap exhausted for idHash=" + str4);
            str5 = "capExhausted";
          }
          paramFlurryAds.onEvent(new gt(str5, Collections.emptyMap(), localContext, localAdUnit, localcw, paramy.bk.jg), this, paramInt + 1);
          return;
          if (!str1.equals("updateViewCount"))
            break;
        }
        while (!paramy.bj.containsKey("idHash"));
        String str3 = (String)paramy.bj.get("idHash");
        localbl1 = this.ho.l(str3);
      }
      while (localbl1 == null);
      localbl1.ad();
      cy.f(p, "updateViewCount:idHash=" + localbl1.ab() + ",newCap=" + localbl1.ae() + ",prevCap=" + localbl1.af() + ",views=" + localbl1.ac());
    }
    while (localbl1.ac() <= localbl1.ae());
    new StringBuilder().append("FlurryAdAction: !! rendering a capped object: ").append(localbl1.ab()).toString();
    return;
    new StringBuilder().append("Unknown action:").append(str1).append(",triggered by:").append(paramy.bk.jf).toString();
  }

  // ERROR //
  public void savePersistentAdLogData()
  {
    // Byte code:
    //   0: aload_0
    //   1: monitorenter
    //   2: aload_0
    //   3: getfield 105	com/flurry/android/FlurryAds:gX	Ljava/io/File;
    //   6: invokestatic 2121	com/flurry/android/an:a	(Ljava/io/File;)Z
    //   9: istore 6
    //   11: iload 6
    //   13: ifne +10 -> 23
    //   16: aconst_null
    //   17: invokestatic 2124	com/flurry/android/fl:a	(Ljava/io/Closeable;)V
    //   20: aload_0
    //   21: monitorexit
    //   22: return
    //   23: new 648	java/io/DataOutputStream
    //   26: dup
    //   27: new 2126	java/io/FileOutputStream
    //   30: dup
    //   31: aload_0
    //   32: getfield 105	com/flurry/android/FlurryAds:gX	Ljava/io/File;
    //   35: invokespecial 2129	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   38: invokespecial 2132	java/io/DataOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   41: astore_2
    //   42: aload_0
    //   43: getfield 130	com/flurry/android/FlurryAds:hv	Ljava/util/List;
    //   46: astore 7
    //   48: aload 7
    //   50: monitorenter
    //   51: aload_0
    //   52: getfield 130	com/flurry/android/FlurryAds:hv	Ljava/util/List;
    //   55: aload_2
    //   56: invokestatic 2137	com/flurry/android/cg:a	(Ljava/util/List;Ljava/io/DataOutput;)V
    //   59: aload 7
    //   61: monitorexit
    //   62: aload_2
    //   63: invokestatic 2124	com/flurry/android/fl:a	(Ljava/io/Closeable;)V
    //   66: goto -46 -> 20
    //   69: astore 5
    //   71: aload_0
    //   72: monitorexit
    //   73: aload 5
    //   75: athrow
    //   76: astore 8
    //   78: aload 7
    //   80: monitorexit
    //   81: aload 8
    //   83: athrow
    //   84: astore_1
    //   85: getstatic 96	com/flurry/android/FlurryAds:p	Ljava/lang/String;
    //   88: ldc_w 2139
    //   91: aload_1
    //   92: invokestatic 1423	com/flurry/android/cy:b	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   95: aload_2
    //   96: invokestatic 2124	com/flurry/android/fl:a	(Ljava/io/Closeable;)V
    //   99: goto -79 -> 20
    //   102: aload 4
    //   104: invokestatic 2124	com/flurry/android/fl:a	(Ljava/io/Closeable;)V
    //   107: aload_3
    //   108: athrow
    //   109: astore_3
    //   110: aload_2
    //   111: astore 4
    //   113: goto -11 -> 102
    //   116: astore_1
    //   117: aconst_null
    //   118: astore_2
    //   119: goto -34 -> 85
    //   122: astore_3
    //   123: aconst_null
    //   124: astore 4
    //   126: goto -24 -> 102
    //
    // Exception table:
    //   from	to	target	type
    //   16	20	69	finally
    //   62	66	69	finally
    //   95	99	69	finally
    //   102	109	69	finally
    //   51	62	76	finally
    //   78	81	76	finally
    //   42	51	84	java/lang/Throwable
    //   81	84	84	java/lang/Throwable
    //   42	51	109	finally
    //   81	84	109	finally
    //   85	95	109	finally
    //   2	11	116	java/lang/Throwable
    //   23	42	116	java/lang/Throwable
    //   2	11	122	finally
    //   23	42	122	finally
  }

  // ERROR //
  public void savePersistentFreqCapData()
  {
    // Byte code:
    //   0: aload_0
    //   1: monitorenter
    //   2: aload_0
    //   3: getfield 125	com/flurry/android/FlurryAds:ho	Lcom/flurry/android/ca;
    //   6: invokevirtual 1634	com/flurry/android/ca:as	()V
    //   9: aload_0
    //   10: getfield 107	com/flurry/android/FlurryAds:gY	Ljava/io/File;
    //   13: invokestatic 2121	com/flurry/android/an:a	(Ljava/io/File;)Z
    //   16: istore 5
    //   18: iload 5
    //   20: ifne +10 -> 30
    //   23: aconst_null
    //   24: invokestatic 2124	com/flurry/android/fl:a	(Ljava/io/Closeable;)V
    //   27: aload_0
    //   28: monitorexit
    //   29: return
    //   30: new 648	java/io/DataOutputStream
    //   33: dup
    //   34: new 2126	java/io/FileOutputStream
    //   37: dup
    //   38: aload_0
    //   39: getfield 107	com/flurry/android/FlurryAds:gY	Ljava/io/File;
    //   42: invokespecial 2129	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   45: invokespecial 2132	java/io/DataOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   48: astore_3
    //   49: aload_0
    //   50: getfield 125	com/flurry/android/FlurryAds:ho	Lcom/flurry/android/ca;
    //   53: astore 6
    //   55: aload 6
    //   57: monitorenter
    //   58: aload_0
    //   59: aload_0
    //   60: getfield 125	com/flurry/android/FlurryAds:ho	Lcom/flurry/android/ca;
    //   63: aload_3
    //   64: invokespecial 2142	com/flurry/android/FlurryAds:a	(Lcom/flurry/android/ca;Ljava/io/DataOutputStream;)V
    //   67: aload 6
    //   69: monitorexit
    //   70: aload_3
    //   71: iconst_0
    //   72: invokevirtual 652	java/io/DataOutputStream:writeShort	(I)V
    //   75: aload_3
    //   76: invokestatic 2124	com/flurry/android/fl:a	(Ljava/io/Closeable;)V
    //   79: goto -52 -> 27
    //   82: astore_1
    //   83: aload_0
    //   84: monitorexit
    //   85: aload_1
    //   86: athrow
    //   87: astore 7
    //   89: aload 6
    //   91: monitorexit
    //   92: aload 7
    //   94: athrow
    //   95: astore_2
    //   96: getstatic 96	com/flurry/android/FlurryAds:p	Ljava/lang/String;
    //   99: ldc_w 607
    //   102: aload_2
    //   103: invokestatic 1423	com/flurry/android/cy:b	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   106: aload_3
    //   107: invokestatic 2124	com/flurry/android/fl:a	(Ljava/io/Closeable;)V
    //   110: goto -83 -> 27
    //   113: aload_3
    //   114: invokestatic 2124	com/flurry/android/fl:a	(Ljava/io/Closeable;)V
    //   117: aload 4
    //   119: athrow
    //   120: astore 4
    //   122: goto -9 -> 113
    //   125: astore_2
    //   126: aconst_null
    //   127: astore_3
    //   128: goto -32 -> 96
    //   131: astore 4
    //   133: aconst_null
    //   134: astore_3
    //   135: goto -22 -> 113
    //
    // Exception table:
    //   from	to	target	type
    //   2	9	82	finally
    //   23	27	82	finally
    //   75	79	82	finally
    //   106	110	82	finally
    //   113	120	82	finally
    //   58	70	87	finally
    //   89	92	87	finally
    //   49	58	95	java/lang/Throwable
    //   70	75	95	java/lang/Throwable
    //   92	95	95	java/lang/Throwable
    //   49	58	120	finally
    //   70	75	120	finally
    //   92	95	120	finally
    //   96	106	120	finally
    //   9	18	125	java/lang/Throwable
    //   30	49	125	java/lang/Throwable
    //   9	18	131	finally
    //   30	49	131	finally
  }

  public void setReportedIds(Map<ReportedIdType, ByteBuffer> paramMap)
  {
    this.aH = paramMap;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.flurry.android.FlurryAds
 * JD-Core Version:    0.6.2
 */